package com.netty.demo.task;

import io.netty.util.internal.PlatformDependent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class Task {

    @Scheduled(fixedRate = 1000)
    public void execute() {
        //16777216 33554432
        //-XX:MaxDirectMemorySize=33554432   //需要配置最大堆外内存大小，不然连接断开不会释放占用的内存
        //addressSize=8, maxDirectMemory=1789919232
        log.info("hasUnsafe={}, usedDirectMemory > maxDirectMemory={} usedDirectMemory={}, maxDirectMemory={}",
                PlatformDependent.hasUnsafe(),
                PlatformDependent.usedDirectMemory() > PlatformDependent.maxDirectMemory(),
                PlatformDependent.usedDirectMemory(),
                PlatformDependent.maxDirectMemory());
    }

}
